package net.streaming.rtsp.server;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

public class RtspResponse {
	private Integer status = 200;
	private Map<String, Object> headers = new LinkedHashMap<String, Object>();
	private String body;

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("RTSP/1.0 "+status+" OK\r\n");
		Set<Entry<String, Object>> entrySet = headers.entrySet();
		for (Entry<String, Object> entry : entrySet) {
			String name = (String) entry.getKey();
			Object value = entry.getValue();
			sb.append(name);
			sb.append(": ");
			sb.append(value);
			sb.append("\r\n");
		}
		sb.append("\r\n");
		
		if(body!=null){
			sb.append(body);
		}
		return sb.toString();
	}

	public Map<String, Object> getHeaders() {
		return headers;
	}

	public void setHeaders(Map<String, Object> headers) {
		this.headers = headers;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}
}